## setup ##

# clean environment
rm(list=ls())

# load packages
library(sandwich)
library(lmtest)
library(tidyverse)

# load data
dat <- read.csv2("data_experiment_outcomes_csv.csv",
                 encoding = 'UTF-8')


# outcome variables as numerics
dat$response <- as.numeric(as.character(dat$response))
dat$quality <- as.numeric(as.character(dat$quality))
dat$response_id <- as.numeric(as.character(dat$response_id))
dat$day_diff <- as.numeric(as.character(dat$day_diff))

# standardize outcome variables
dat$response_scaled <- scale(dat$response)
dat$quality_scaled <- scale(dat$quality)
dat$response_id_scaled <- scale(dat$response_id)
dat$day_diff_scaled <- scale(dat$day_diff)


## models

# column 1
mod_1 <- lm(response_scaled~immback+partisan, data=dat)

# column 2
mod_2 <- lm(quality_scaled~immback+partisan, data=dat)

# column 3
mod_3 <- lm(response_id_scaled~immback+partisan, data=dat)

# column 4
mod_4 <- lm(day_diff_scaled~immback+partisan, data=dat)


## robust standard errors

# column 1
mod_1_rob <- coeftest(mod_1, vcov = vcovHC(mod_1, "HC1"))

# column 2
mod_2_rob <- coeftest(mod_2, vcov = vcovHC(mod_2, "HC1"))

# column 3
mod_3_rob <- coeftest(mod_3, vcov = vcovHC(mod_3, "HC1"))

# column 4
mod_4_rob <- coeftest(mod_4, vcov = vcovHC(mod_4, "HC1"))


## show coefficients and SEs
mod_1_rob
mod_2_rob
mod_3_rob
mod_4_rob

